<h:form id="formFichaExtraOrcamentaria" 
        xmlns="http://www.w3.org/1999/xhtml"
        xmlns:h="http://java.sun.com/jsf/html"
        xmlns:p="http://primefaces.org/ui"
        xmlns:pe="http://primefaces.org/ui/extensions"
        xmlns:f="http://java.sun.com/jsf/core">

    <script language="JavaScript" src = "scripts/script.js"/>
    <script language="JavaScript" src = "scripts/mask.js"/>

    <h:panelGrid style="width: 100%" >

        <h:panelGroup>

            <h:outputLabel value="Inclusão" /><br/>
            <p:calendar value="#{fichaExtraOrcamentariaBean
                                 .fichaExtraOrcamentaria.dataInclusao}"
                        maxlength="10"
                        showOn="button"
                        pattern="dd/MM/yyyy"
                        onkeypress="mascara(this, data)">

                <p:ajax event="dateSelect" 
                        update="saldoBalanco"  />

                <p:ajax event="change" 
                        update="saldoBalanco"  />

            </p:calendar>


        </h:panelGroup>

        <h:panelGroup>

            <h:outputLabel value="Unidade Gestora" /><br/>
            <p:selectOneMenu value="#{fichaExtraOrcamentariaBean.fichaExtraOrcamentaria.unidadeGestora}" 
                             style="width: 100%">
                <f:selectItem itemLabel="Selecione" />
                <f:selectItems value="#{fichaExtraOrcamentariaBean.unidadesGestoras}" />
                <f:converter converterId="simpleEntityConverter" />

                <p:ajax event="change" update="contaExtra"/>

            </p:selectOneMenu>

        </h:panelGroup>

    </h:panelGrid>

    <h:panelGrid columns="2" style="width: 100%" >

        <h:panelGroup>
            <h:outputLabel value="Conta Extra" /><br/>
            <p:selectOneMenu id="contaExtra" value="#{fichaExtraOrcamentariaBean
                                                      .fichaExtraOrcamentaria.contaExtra}" 
                             style="width: 190px">
                <f:selectItem itemLabel="Selecione" />
                <f:selectItems value="#{fichaExtraOrcamentariaBean.contasExtra}" />
                <f:converter converterId="simpleEntityConverter" />
            </p:selectOneMenu>
        </h:panelGroup>

        <h:panelGroup>

            <h:outputLabel value="Ficha Extra" /><br/>
            <p:inputText value="#{fichaExtraOrcamentariaBean.fichaExtraOrcamentaria.fichaExtra}" 
                         style="width: 190px"/>

        </h:panelGroup>
    </h:panelGrid>

    <h:panelGrid style="width: 100%" >

        <h:panelGroup>

            <h:outputLabel value="Tipo Extra" /><br/>
            <p:selectOneMenu value="#{fichaExtraOrcamentariaBean.fichaExtraOrcamentaria.tipoExtra}" 
                             style="width: 100%">

                <f:selectItem itemLabel="Selecione" />
                <f:selectItems value="#{fichaExtraOrcamentariaBean.tiposExtra}" />
                <f:converter converterId="simpleEntityConverter" />

            </p:selectOneMenu>

        </h:panelGroup>

    </h:panelGrid>

    <h:panelGrid style="width: 100%" 
                 columns="2">

        <h:panelGroup>

            <h:outputLabel value="Educação 25" /><br/>
            <p:selectOneMenu value="#{fichaExtraOrcamentariaBean.fichaExtraOrcamentaria.educacao25}" 
                             style="width: 190px">

                <f:selectItem itemLabel="Selecione" />
                <f:selectItems value="#{fichaExtraOrcamentariaBean.confirmacoes}" />
                <f:converter converterId="simpleEntityConverter" />

            </p:selectOneMenu>

        </h:panelGroup>

        <h:panelGroup>

            <h:outputLabel value="Saúde 15" /><br/>
            <p:selectOneMenu value="#{fichaExtraOrcamentariaBean.fichaExtraOrcamentaria.saude15}" 
                             style="width: 190px">

                <f:selectItem itemLabel="Selecione" />
                <f:selectItems value="#{fichaExtraOrcamentariaBean.confirmacoes}" />
                <f:converter converterId="simpleEntityConverter" />

            </p:selectOneMenu>

        </h:panelGroup>

    </h:panelGrid>

    <h:panelGrid style="width: 100%">

        <h:panelGroup>

            <h:outputLabel value="Histórico" /><br/>
            <p:inputTextarea value="#{fichaExtraOrcamentariaBean.fichaExtraOrcamentaria.historico}" 
                             style="width: 98%"
                             autoResize="false"/>

        </h:panelGroup>

    </h:panelGrid>

    <h:panelGrid columns="2"
                 style="width: 100%" >

        <h:panelGroup>

            <h:outputLabel value="Inclusão" /><br/>
            <p:calendar value="#{fichaExtraOrcamentariaBean.fichaExtraOrcamentaria.dataInclusao }"
                        maxlength="10"
                        pattern="dd/MM/yyyy"
                        onkeypress="mascara(this, data)">
                <p:ajax event="blur" update="saldoBalanco"/>
            </p:calendar>


        </h:panelGroup>

        <h:panelGroup>

            <h:outputLabel value="Saldo" /><br/>
            <pe:inputNumber id="saldoBalanco" 
                            value="#{fichaExtraOrcamentariaBean
                                     .fichaExtraOrcamentaria.saldoBalanco}" 
                            symbol="R$" 
                            thousandSeparator="." 
                            decimalSeparator=","
                            disabled="#{!fichaExtraOrcamentariaBean.fichaExtraOrcamentariaService
                                        .verificaDataDeInclusao(fichaExtraOrcamentariaBean
                                        .fichaExtraOrcamentaria)}"/>

        </h:panelGroup>

    </h:panelGrid>

    <hr/>

    <p:commandButton id="btnGravar" value="Gravar" 
                     actionListener="#{fichaExtraOrcamentariaBean.adicionarEditarFim}"
                     update="formFichaExtraOrcamentaria" />

    <p:commandButton value="Cancelar" 
                     actionListener="#{fichaExtraOrcamentariaBean.cancelar}"
                     immediate="true"/>

</h:form>


